﻿using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.Xpo;
using Component;

namespace Component
{
    public class CartDB:Base
    {
        /// <summary>
        /// public static XPCollection<Cart> GetAll()
        /// </summary>
        /// <returns>XPCollection<Cart></returns>
        public static XPCollection<Cart> GetAll(bool admin)
        {
            XPCollection<Cart> _xpCart = new XPCollection<Cart>(KetNoiCSDL.session);
            _xpCart.Filter = FilterAll(admin);
            return _xpCart;
        }
        /// <summary>
        /// public static Cart GetObjectByid(int id)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Cart GetObjectByid(int id)
        {
            XPCollection<Cart> _xpCart = new XPCollection<Cart>(KetNoiCSDL.session);
            _xpCart.Filter = FilterById(id, true);
            if (_xpCart.Count > 0)
            {
                return _xpCart[0];
            }
            return null;
        }  
    }
}
